import { getListApi } from "@/api/managementCenter/roleAndPermission";
import { reactive } from "vue";

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "用户名",
    keyName: "username"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "角色",
    keyName: "roleId",
    optionsRequest: getListApi,
    optReqParams: { name: "", status: 1, pageNum: 1, pageSize: 10000, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  }),
  {
    type: "select",
    label: "状态",
    keyName: "status",
    optConfig: {
      label: "label",
      value: "value"
    },
    options: [
      {
        label: "启用",
        value: 1
      },
      {
        label: "停用",
        value: 0
      }
    ]
  }
];

// 列表
export const tableColumn: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem> = [
  {
    field: "checkbox",
    type: "checkbox",
    minWidth: "50"
  },
  {
    field: "username",
    title: "用户名",
    minWidth: "140"
  },
  {
    field: "name",
    title: "姓名",
    minWidth: "90"
  },
  {
    field: "deptName",
    title: "部门",
    minWidth: "120"
  },
  {
    field: "roleName",
    title: "角色",
    minWidth: "180"
  },
  {
    field: "phone",
    title: "手机号",
    minWidth: "90"
  },
  {
    field: "status",
    title: "状态",
    minWidth: "120",
    renderSlot: "status"
  },
  {
    field: "action",
    title: "操作",
    minWidth: "160",
    renderSlot: "action"
  }
];
